#include <bits/stdc++.h>

using namespace std;

int main() {
    string a;
    cin>>a;
    int b = 0;
    for (int i = 0; i < a.length(); ++i) {
        int c = a.length()-i-1;
        if (a[i]>=48 && a[i] <= 57){
            b+=(a[i]-'0')*pow(16,c);
        }
        if(a[i]>='A'&&a[i]<='F'){
            b+=(a[i]-'A'+10)*pow(16,c);
        }
        if (a[i]>='a'&&a[i]<='f'){
            b+=(a[i]-'a'+10)*pow(16,c);
        }
    }
    cout<<b;
}
